filename = '1.png'
import pygame
from pygame.locals import *
from sys import exit

pygame.init()
screen = pygame.display.set_mode((400, 300))
pygame.display.set_caption("Moving with mouse")
img = pygame.image.load(filename)
x = 0
y = 150

while True:
    mx, my = pygame.mouse.get_pos()
    screen.fill((255, 255, 255))  # 填充背景色为白色
    screen.blit(img, (mx, my))  # 在 (mx, my) 位置绘制图片

    for event in pygame.event.get():
        if event.type == QUIT:  # 注意这里 QUIT 应为全大写
            exit()

    pygame.display.update()